﻿namespace TimeSpan.Views.Dialogs;

public partial class NewPresetWindow : IEditor<SpanTaskOption> {
    private SpanTaskOption? objectToEdit;

    public SpanTaskOption? ObjectToEdit { 
        get => objectToEdit; 
        set {
            objectToEdit = value;
            ViewModel.SetData(value);
        }  
    }
    public NewPresetWindowViewModel ViewModel { get; } = new();

    public NewPresetWindow() {
        InitializeComponent();
    }

    private void Close_Click(object sender, System.Windows.RoutedEventArgs e) {
        DialogResult = false;
    }

    private void Slice_Click(object sender, System.Windows.RoutedEventArgs e) {
        ObjectToEdit = ViewModel.Slice(SpanSlider.Value);
        DialogResult = true;
    }
}